package com.five.monkey.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author jim
 * @desc
 * @date 2021-08-15 13:34
 */
public enum OperateTypeEnum {

    DEFAULT("", "默认类型,为了match方法不返回null"),

    USER("user", "用户操作类型"),

    GRAPH("graph", "图谱操作类型");

    private String operateType;

    private String desc;

    OperateTypeEnum(String operateType, String desc) {
        this.operateType = operateType;
        this.desc = desc;
    }

    public static OperateTypeEnum match(String operateType) {
        OperateTypeEnum operateTypeEnum = OperateTypeEnum.DEFAULT;
        if (StringUtils.isNotBlank(operateType)) {
            OperateTypeEnum[] operateTypeEnums = OperateTypeEnum.values();
            for (OperateTypeEnum typeEnum : operateTypeEnums) {
                if (StringUtils.equalsIgnoreCase(operateType, typeEnum.operateType)) {
                    operateTypeEnum = typeEnum;
                    break;
                }
            }
        }
        return operateTypeEnum;
    }
}
